package com.qcby.types.enums;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author cong.zhen
 * @date 2024/04/10
 */
@Getter
@AllArgsConstructor
public enum CommonStatusEnum {

    ENABLE(0, "开启"),
    DISABLE(1, "关闭"),
    NO(0, "否"),
    YES(1, "是");

    /**
     * 状态值
     */
    private final Integer status;
    /**
     * 状态名
     */
    private final String name;

    /**
     * 根据code获取名称
     * @param status
     * @return {@link String }
     */
    public static String getNameByStatus(Integer status) {
        if(ObjectUtil.isNull(status)){
            return StrUtil.EMPTY;
        }
        for (CommonStatusEnum statusEnum : CommonStatusEnum.values()) {
            if (statusEnum.getStatus().equals(status)) {
                return statusEnum.getName();
            }
        }
        return StrUtil.EMPTY;
    }
}
